﻿@using Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.Components
@using Volo.Abp.AspNetCore.Mvc.UI.Layout
@using Volo.Abp.UI.Navigation
@using EasyAbp.Abp.AspNetCore.Mvc.UI.Theme.LYear.Themes.LYear.Components.Menu
@inject IBrandingProvider BrandingProvider
@inject IPageLayout PageLayout
@model ApplicationMenu
<!--左侧导航-->
<aside class="lyear-layout-sidebar">

    <!-- logo -->
    <div id="logo" class="sidebar-header">
        <a href="~/">
            <a style="line-height: 50px;font-weight: bold;" href="~/">@BrandingProvider.AppName</a>
        </a>
    </div>
    <div class="lyear-layout-sidebar-scroll">

        <nav class="sidebar-main">
            <ul class="nav nav-drawer">
                @foreach (var menuItem in Model.Items)
                {
                    var url = string.IsNullOrEmpty(menuItem.Url) ? "#" : Url.Content(menuItem.Url);
                    var childOepn = LeftNavbarMenuViewComponent.ChildActive(menuItem.Items, PageLayout.Content.MenuItemName) ? "open" : "";
                    var active = PageLayout.Content.MenuItemName == Model.Name ? "active" : "";
                    var childActive = LeftNavbarMenuViewComponent.ChildActive(menuItem.Items, PageLayout.Content.MenuItemName) ? "active" : "";

                    if (menuItem.IsLeaf)
                    {
                        if (menuItem.Url != null)
                        {
                            <li class="nav-item  @active">
                                <a href="@url">
                                    <i class="@LeftNavbarMenuViewComponent.ReWriteIcon(menuItem.Name, menuItem.Icon)"></i>@(menuItem.DisplayName)
                                </a>
                            </li>
                        }
                    }
                    else
                    {
                        <li class="nav-item nav-item-has-subnav @childOepn @childActive">
                            <a href="javascript:void(0)">
                                <i class="@LeftNavbarMenuViewComponent.ReWriteIcon(menuItem.Name, menuItem.Icon)"></i>@(menuItem.DisplayName)
                            </a>
                            @foreach (var childMenuItem in menuItem.Items)
                            {
                                @await Html.PartialAsync("~/Themes/LYear/Components/Menu/_MenuItem.cshtml", childMenuItem)
                            }
                        </li>
                    }

                }
            </ul>
        </nav>
    </div>

</aside>
<!--End 左侧导航--> 